﻿using LJ.Host.Worker.Extensions;
using Microsoft.Extensions.Hosting;

namespace LJ.Host.Worker;

public class WorkerHostStartup
{
    public static async Task RunAsync(string[] args)
    {

        var builder = Microsoft.Extensions.Hosting.Host.CreateApplicationBuilder(args);

        builder.Services.AddLJ(builder.Configuration);

        var host = builder.Build();

        host.Services.UseLJ();

        AppDomain.CurrentDomain.ProcessExit += async (sender, eventArgs) =>
        {
            try
            {
                await host.StopAsync();

            }
            catch
            {

            }
        };
        await host.RunAsync();
    }
}
